﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HitachiLib.HitachiServiceRef;

namespace HitachiLib.Data
{
    public class ProjectResourceRelation
    {
        private ProjectResourceData data;
        private static Dictionary<int, ProjectResourceRelation> s_map = new Dictionary<int, ProjectResourceRelation>();

        public ProjectResourceData Data
        {
            get { return data; }
        }
        public static ProjectResourceRelation GetUnique(ProjectResourceData pd)
        {
            if (s_map.ContainsKey(pd.ID))
            {
                return s_map[pd.ID];
            }
            ProjectResourceRelation r = new ProjectResourceRelation(pd);
            s_map.Add(pd.ID, r);
            return r;
        }
        public static ProjectResourceRelation GetUnique(int id)
        {
            if (s_map.ContainsKey(id))
            {
                return s_map[id];
            }
            return null;
        }
        public static List<ProjectResourceRelation> GetByResourceId(int resource_id)
        {
            List<ProjectResourceRelation> result = new List<ProjectResourceRelation>();
            foreach (ProjectResourceRelation prjres in s_map.Values)
            {
                result.Add(prjres);
            }
            return result;
        }

        public ProjectResourceRelation(ProjectResourceData prd)
        {
            data = prd;
        }
    }
}
